package SimpleFactory.test01consumer;

import SimpleFactory.test01.Pizza;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

public class OrderPizza2 {

    Pizza pizza=null;
    String orderType="";
    //构造器
    public OrderPizza2(){
        do {
            orderType=getType();
            pizza=SimpleFactory.createPizza2(orderType);

            //输出pizza
            if (pizza!=null){
                pizza.perpare();
                pizza.bake();
                pizza.cut();
                pizza.box();
            }else{
                System.out.println(" 订购披萨失败 ");
                break;
            }
        }while (true);
    }


    //写一个方法，可以动态获取客户订购的披萨种类
    private String getType(){
        try{
            InputStream in;
            BufferedReader strin=new BufferedReader(new InputStreamReader(System.in));
            System.out.println("input pizza 种类:");
            String str=strin.readLine();
            return str;
        } catch (IOException e) {
            e.printStackTrace();
            return "";
        }
    }
}
